﻿{include file="public/header" /}
  <body>
    <div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">人力资源</a>
        <a>
          <cite>员工列表</cite>
        </a>
      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <xblock>
        <a class="layui-btn"  target="_blank" href="{:url()}"><i class="iconfont">&#xe718;</i> 框架页面</a>

        <!--<button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>-->
        <button class="layui-btn" onclick="x_admin_show('添加员工','{:url(\'index/Employee/employeeAdd\')}',500,550)"><i class="layui-icon"></i>添加</button>
        <span class="x-right" style="line-height:40px">共有数据：{$employeeInfoCount}条· 共{$employeeInfoCount/100|getInt}页</span>

      </xblock>
      <div class="container-wrap">
        <div class="box-1">
          <table class="layui-table">
            <thead>
            <tr>
            <!--<th>-->
              <!--<div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>-->
            <!--</th>-->
            <th  width="40px;">操作</th>
            <th>员工编号</th>
            <th>员工姓名</th>
            <th>手机号</th>
            <th>部门名称</th>
            <th>职务名称</th>
              <th>备注</th>
              <th>身份</th>
              <th>定额权限</th>
              <th>价格权限</th>
              <th>报价权限</th>
            <th>身份证号码</th>
            <th>银行卡号</th>
            <th>业主</th>
            <th>是否离职</th>
            <th>开户行</th>
            <th>进厂日期</th>
            <th>离职日期</th>
            <th>创建时间</th>
            <th>更新时间</th>
        </thead>
        <tbody>
        {volist name="employeeInfo" id = "info"}
          <tr>
            <!--<td>-->
              <!--<div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id='2'><i class="layui-icon">&#xe605;</i></div>-->
            <!--</td>-->
            <td>
              <a title="编辑"onclick="x_admin_show('修改操作','{:url(\'index/Employee/employeeEdit\',[\'id\'=>$info.id])}',500,550)" href="javascript:;">
                <i style="color: green" class="layui-icon"></i>
              </a>
              <a title="删除" onclick="delete_(this,'{$info.id}')" href="javascript:;">
                <i  style="color:red;" class="layui-icon"></i>
              </a>
              {if  $Think.session.user.admin == 'admin'}
              {if $info.employee_lv == 0}
              <a title="设置为管理员" onclick="admin('{$info.id}','1')" href="javascript:;">
                <i class="layui-icon layui-icon-username"></i>
              </a>
              {else/}
              <a title="取消管理员" onclick="admin('{$info.id}','0')" href="javascript:;">
                <i class="layui-icon layui-icon-close"></i>
              </a>
              {/if}
              {/if}
            </td>
            <td>{$info.employee_code}</td>
            <td>{$info.employee_name}</td>
            <td>{$info.tle}</td>
            <td>
              {if $info.department_name == ''}
              未指定
              {else}
              {$info.department_name}
              {/if}
            </td>
            <td>
              {if $info.duties_name == ''}
              未指定
              {else}
              {$info.duties_name}
              {/if}
            </td>
            <td>{$info.annotation}
            <td>
            {if $info.employee_lv == 0}
             普通员工
            {else}
            管理员
            {/if}
           </td>
            <td>
              {if $info.is_quota == 1}
              修改
              {else}
              查看
              {/if}
            </td>
            <td>
              {switch name=" $info.is_price"}
              {case value="0"}隐藏{/case}
              {case value="1"}查看{/case}
              {case value="2"}修改{/case}
              {default /}
              {/switch}
            </td>
            <td>
              {switch name=" $info.is_offer"}
              {case value="0"}隐藏{/case}
              {case value="1"}查看{/case}
              {case value="2"}修改{/case}
              {default /}
              {/switch}
            </td>
            <td>{$info.id_card_no}</td>
            <td>{$info.bank_card}</td>
            <td>{$info.owner}</td>
            <td>
              {if $info.is_leftis != 0}
              是
              {else}
              否
              {/if}
            </td>
            <td>{$info.opening_bank}</td>
            <td>{$info.factory_date}</td>
            <td>{$info.leave_date}</td>
            <td>{$info.create_time}</td>
            <td>{$info.update_time}</td>
          </tr>
        {/volist}
        </tbody>
      </table>
        </div>
      </div>
      </div>
      <div class="page">
        {$employeeInfo|raw}
    </div>
    <script>
     function admin(id,admin) {
         $.ajax({
             url:"{:url('/index/Employee/employeeLv')}",
             type:"POST",
             dataType:"json",
             data:{
                 id:id,
                 admin:admin   //数据
             },
             success:function (res) {
                 if(res === 1 ){
                     layer.alert("更改成功", {icon: 6},function () {
                         window.location.reload();  //刷新父级页面
                     });
                 }else {
                     layer.alert("更改失败", {icon: 5});
                 }
             },
         });
     }
     /*删除*/
     function delete_(obj,id){
         layer.confirm('确认要删除吗？',function(index){
             var url = "<?php echo url('/index/Employee/delete'); ?>";
             var postData ={"id":id};
             $.post(url,postData,function (result) {
                 if(result === 1 ){
                     $(obj).parents("tr").remove();
                     layer.msg('已删除!',{icon:1,time:1000});
                 }else {
                     layer.alert("删除失败", {icon: 5});
                 }
             },"json");
         });
     }
    </script>
  </body>

</html>